package cn.zh.npro.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import cn.zh.npro.Item.GmItem;
import cn.zh.npro.R;

/**
 * Created by WYN on 2018/3/12 0012.
 */

public class GAdapter extends BaseAdapter{
   Context context;
   ArrayList<GmItem> arrayList;
   LayoutInflater inflater;
   public GAdapter(Context context,ArrayList<GmItem> arrayList){
       this.context=context;
       this.arrayList=arrayList;
       inflater=LayoutInflater.from(context);
      }



    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return arrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        Holder holder=null;
        if (null==view){
            holder=new Holder();
            view=inflater.inflate(R.layout.gm_layout,null,false);
            holder.tytxt=view.findViewById(R.id.tytxt);
            holder.snum=view.findViewById(R.id.snum);
            holder.renum=view.findViewById(R.id.renum);
           view.setTag(holder);
          }else {
            holder= (Holder) view.getTag();
           }
        holder.tytxt.setText(arrayList.get(i).getLv());
        holder.snum.setText(arrayList.get(i).getBaseline());
        holder.renum.setText("¥"+arrayList.get(i).getPrice());

        return view;
        }


    public class Holder{
     TextView tytxt,snum,renum;
      }


   }
